package io.jee.medusa.service.impl;

import io.jee.medusa.orm.condition.ConditionGroup;
import io.jee.medusa.orm.pager.Pager;
import io.jee.medusa.service.ServiceInterface;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public abstract class BaseService<T> implements ServiceInterface<T> {

	@Override
	public Serializable save(T entity) {
		return getDao().save(entity);
	}

	@Override
	public void save(Collection<T> entitys) {
		getDao().save(entitys);
	}

	@Override
	public void saveOrUpdate(T entity) {
		getDao().saveOrUpdate(entity);
	}

	@Override
	public void update(T entity) {
		getDao().update(entity);
	}
	
	@Override
	public void update(String key, Object value, ConditionGroup group) {
		getDao().update(key, value, group);
	}

	@Override
	public void delete(T entity) {
		getDao().delete(entity);
	}

	@Override
	public int delete(String key, Object value) {
		return getDao().delete(key, value);
	}

	@Override
	public int delete(String key, Object[] values) {
		return getDao().delete(key, values);
	}
	
	@Override
	public int delete(ConditionGroup group) {
		return getDao().delete(group);
	}

	@Override
	public void update(String key, Object value, Serializable id) {
		getDao().update(key, value, id);
	}

	@Override
	public T get(Serializable id) {
		return getDao().get(id);
	}

	@Override
	public T get(ConditionGroup group) {
		return getDao().get(group);
	}

	@Override
	public T load(Serializable id) {
		return getDao().load(id);
	}

	@Override
	public T unique(String key, Object value) {
		return getDao().unique(key, value);
	}

	@Override
	public List<T> list(String key, Object value) {
		return getDao().list(key, value);
	}

	@Override
	public List<T> list(String key, Object value, String shortType,
			String shortProperty) {
		return getDao().list(key, value, shortType, shortProperty);
	}

	@Override
	public List<T> list(String key, Object[] values) {
		return getDao().list(key, values);
	}

	@Override
	public List<T> list(Map<String, Object> params) {
		return getDao().list(params);
	}

	@Override
	public List<T> list(ConditionGroup group) {
		return getDao().list(group);
	}

	@Override
	public Pager<T> list(Pager<T> pager, ConditionGroup group) {
		return getDao().list(pager, group);
	}

	@Override
	public Pager<T> list(Pager<T> pager, ConditionGroup group,
			String orderType, String orderProperty) {
		return getDao().list(pager, group, orderType, orderProperty);
	}

	@Override
	public List<T> listAll() {
		return getDao().listAll();
	}

	@Override
	public List<T> listAll(String orderType, String orderProperty) {
		return getDao().listAll(orderType, orderProperty);
	}

	@Override
	public long count(String key, Object value) {
		return getDao().count(key, value);
	}

	@Override
	public long count(ConditionGroup group) {
		return getDao().count(group);
	}

	@Override
	public long count(Map<String, Object> params) {
		return getDao().count(params);
	}

	@Override
	public long countAll() {
		return getDao().countAll();
	}

}
